<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the warnings and errors</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetime.createfromformat.html">DateTime::createFromFormat</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.modify.html">DateTime::modify</a></div>
 <div class="up"><a href="class.datetime.html">DateTime</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="datetime.getlasterrors" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTime::getLastErrors</h1>
  <h1 class="refname">date_get_last_errors</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0)</p><p class="refpurpose"><span class="refname">DateTime::getLastErrors</span> -- <span class="refname">date_get_last_errors</span> &mdash; <span class="dc-title">Returns the warnings and errors</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetime.getlasterrors-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">array</span> <span class="methodname"><strong>DateTime::getLastErrors</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><a href="function.date-get-last-errors.html" class="methodname">date_get_last_errors</a></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Returns an array of warnings and errors found while parsing
   a date/time string.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-datetime.getlasterrors-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetime.getlasterrors-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns array containing info about warnings and errors.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-datetime.getlasterrors-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2191">
   <p><strong>Example #1 <span class="function"><strong>DateTime::getLastErrors()</strong></span> example</strong></p>
   <div class="example-contents"><p>面向对象风格</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$date&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">'asdfasdf'</span><span style="color: #007700">);<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;For&nbsp;demonstration&nbsp;purposes&nbsp;only...<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">::</span><span style="color: #0000BB">getLastErrors</span><span style="color: #007700">());<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;The&nbsp;real&nbsp;object&nbsp;oriented&nbsp;way&nbsp;to&nbsp;do&nbsp;this&nbsp;is<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;echo&nbsp;$e-&gt;getMessage();<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>过程化风格</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">date_create</span><span style="color: #007700">(</span><span style="color: #DD0000">'asdfasdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">date_get_last_errors</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
   [warning_count] =&gt; 1
   [warnings] =&gt; Array
       (
           [6] =&gt; Double timezone specification
       )

   [error_count] =&gt; 1
   [errors] =&gt; Array
       (
           [0] =&gt; The timezone could not be found in the database
       )

)
</pre></div>
   </div>
   <div class="example-contents"><p>
    The indexes 6, and 0 in the example output refer to the character index in the string where the error occurred.
   </p></div>
  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetime.createfromformat.html">DateTime::createFromFormat</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.modify.html">DateTime::modify</a></div>
 <div class="up"><a href="class.datetime.html">DateTime</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
